import { capitalize } from 'lodash';
import { useTranslation } from 'react-i18next';
import { useLocation } from 'react-router-dom';

const useTitle = () => {
  const location = useLocation();
  const { t } = useTranslation();

  if (location.pathname === '/') {
    return t('home');
  } else if (['/instructions', '/database', '/user'].includes(location.pathname)) {
    return t(location.pathname.split('/')[1]);
  } else {
    return capitalize(location.pathname.split('/')[1]);
  }
};

export default useTitle;
